/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package control;

import global.CurrentUserInfor;
import global.Global;
import global.ServerInfor;

import java.io.IOException;
import java.io.InputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import obj.NguoiDung;
import obj.ObjDiem;
import obj.objResponseScore;
import view.ShowAlert;

/**
 *
 * @author kUN
 */
public class LayDuLieuDiem {
    
        
     public static objResponseScore LayDuLieu(String sUserName, String iHocKy)
        {
            HttpConnection http = null;
            InputStream iStrm = null;  
            boolean bRes = false;
            //int iRes = -1;
            objResponseScore response=null;

        String url = ServerInfor.url + "/mobile/ViewScore.aspx"  + "?" +
                "sUserName=" + sUserName + "&" + 
                "iKyHoc=" + iHocKy;

        try
        {
          http = (HttpConnection) Connector.open(url);
          http.setRequestMethod(HttpConnection.GET);
          iStrm = http.openInputStream();      

          bRes = ProcessServerResponse.ServerResponse(http, iStrm);
          if(bRes == true)
          {
              if(Global.sServerRespon.equals("false") || Global.sServerRespon.equals(null))
              {
               
              }
              else
              {
                  response=new objResponseScore();
                  response.fromJSON(Global.sServerRespon);
                              
                //   iRes = 1;
              }
          }
        }
        catch(IOException ex)
        {
            //ShowAlert.ShowAlert(display, frm, "Lỗi kết nối", "Không  thể kết nối với Server", 3);
        }
        finally
        {
            try
            {
              if (iStrm != null)
                iStrm.close();
              if (http != null)
                http.close();
            }
            catch(IOException ex){}
        }
        return response;            
        }       
}
